package com.usian.listener;

import com.usian.service.WemediaNewsAutoScanService;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class MsgListener {

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @KafkaListener(topics = "autoScanNews")
    public void receiverMessage(ConsumerRecord<?,?> record){
        Optional<? extends ConsumerRecord<?, ?>> optional = Optional.ofNullable(record);
        if(optional.isPresent()){
            Object value = record.value();
            //user json串
            wemediaNewsAutoScanService.autoScanByMediaNewsId(Integer.valueOf(value.toString()));
        }
    }
}
